#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin>>n;
    vector<int> a(n),pos(n+1);
    int mx=0,l=n,r=0;
    for(int i=0;i<n;i++){
    	cin>>a[i];
    	pos[a[i]]=i;
    	if(mx<a[i]){
    		mx=a[i];
    		l=i;
    		r=i;
    	}
    }

    for(int i=n;i>=2;i--){
    	if(min(abs(pos[i-1]-l),abs(pos[i-1]-r))>1){
    		cout<<"NO"<<'\n';
    		return;
    	}else{
    		l=min(l,pos[i-1]);
    		r=max(r,pos[i-1]);
    	}
    }
    cout<<"YES"<<'\n';
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0),cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}